using Hu.Core.Domains.Admin.Context;
using Hu.Core.Domains.Admin.Service;
using Hu.Core.Domains.Basic.Base;
using Hu.Core.Domains.Basic.Service;
using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

var services = builder.Services;

services.AddScoped(x =>
{
    var configuration = x.GetRequiredService<IConfiguration>();
    return new HuBaseDbContext(configuration);
});

services.AddDbContext<HuAdminDbContext>();
services.AddScoped<HuUserService>();

// Add services to the container.
builder.Services.AddRazorPages();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();

app.UseRouting();

app.MapControllerRoute(
    name: "areaRoute",
    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.UseAuthorization();

app.MapRazorPages();

app.Run();
